<?php
$isDefaultPeriod = true;
$period = RM_Reservation_Period::getDefault();

$criteria = RM_Reservation_Manager::getInstance()->getCriteria();
if ($criteria !== null) {
    if ($criteria->start_datetime && $criteria->end_datetime) {
        $isDefaultPeriod = false;
        $period = new RM_Reservation_Period(
            new RM_Date(strtotime($criteria->start_datetime)),
            new RM_Date(strtotime($criteria->end_datetime))
        );
    }
    $persons = new RM_Reservation_Persons(array("adults"=>$criteria->adults,"children"=>$criteria->children,"infants"=>$criteria->infants));
} else {
    $persons = new RM_Reservation_Persons(); // create with default value
}

$information = new RM_Prices_Information($this->unit, $period, $persons);
$priceSystem = RM_Environment::getInstance()->getPriceSystem();
$config = new RM_Config();
$currencySymbol = $config->getValue('rm_config_currency_symbol');
$showPriceWithTax = (bool)$config->getValue('rm_config_prices_with_tax');
if ($showPriceWithTax) {
    $taxSystem = RM_Environment::getInstance()->getTaxSystem();
}

// panel config
$panelsettings = Zend_Json::decode($this->panel->settings);
?>
<div id="<?php echo $this->panel->getDivID(); ?>" >
    <div class="RM_unit_list_price_container">
        <div class="RM_unit_list_price_text_container" style="text-align:<?php echo $panelsettings['align'];?>">
            <?php
            $lowestUnitPrice = $priceSystem->getLowestUnitPrice($information);
            if ($lowestUnitPrice != 0) {
                if ($showPriceWithTax) {
                    $lowestUnitPrice += $taxSystem->calculateTotalTax($this->unit, $lowestUnitPrice);
                }
            ?>
                <span class="RM_unit_list_price_text"><?php echo $this->_translate->_('User.Unit.List','RatesFrom');?>: </span><span class="RM_unit_list_price_value"><?php echo $currencySymbol; ?><?php echo $lowestUnitPrice; ?></span>
            <?php }  else { ?>
                <span class="RM_unit_list_price_text"><?php echo $this->_translate->_('User.Unit.List','PricesNA');?></span>
            <?php } ?>
        </div>
    </div>
</div>
